home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_VB / SETUPK.ZIP;1 / SETUP1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-10-14  |  15.0 KB  |  353 lines

  1. VERSION 2.00
  2. Begin Form Setup1 
  3.    BackColor       =   &H00400000&
  4.    Caption         =   "Test App Setup"
  5.    ClientHeight    =   2130
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2610
  8.    ClientWidth     =   5640
  9.    ControlBox      =   0   'False
  10.    FillStyle       =   0  'Solid
  11.    FontBold        =   -1  'True
  12.    FontItalic      =   -1  'True
  13.    FontName        =   "MS Sans Serif"
  14.    FontSize        =   24
  15.    FontStrikethru  =   0   'False
  16.    FontUnderline   =   0   'False
  17.    ForeColor       =   &H00000000&
  18.    Height          =   2535
  19.    Icon            =   SETUP1.FRX:0000
  20.    Left            =   1800
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form3"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   142
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   376
  28.    Top             =   2265
  29.    Width           =   5760
  30.    Begin Label Label2 
  31.       BorderStyle     =   1  'Fixed Single
  32.       Caption         =   "To customize this setup program, modify the FORM_LOAD event procedure in this form."
  33.       Height          =   435
  34.       Left            =   15
  35.       TabIndex        =   1
  36.       Top             =   15
  37.       Visible         =   0   'False
  38.       Width           =   5625
  39.    End
  40.    Begin Label Label1 
  41.       BorderStyle     =   1  'Fixed Single
  42.       Caption         =   "This label used for DDE connection to the Program Manager"
  43.       Height          =   390
  44.       Left            =   15
  45.       TabIndex        =   0
  46.       Top             =   525
  47.       Visible         =   0   'False
  48.       Width           =   5610
  49.    End
  50. 'Version = 1.00.002
  51. Const APPNAME = "Loan Application"
  52. Const APPDIR = "C:\LOAN"    ' The default install directory
  53. Const fDataAccess% = False
  54. Const fODBC% = False
  55. Const fBtrieve% = False
  56. Const fOLE2% = False
  57. ' Set the total uncompressed file sizes
  58. ' by adding the sizes of the files
  59. Const WINSYSNEEDED = 40896  ' Files that go into WINDOWS and SYSTEM directory
  60. Const OTHERNEEDED = 12555   ' Files that don't go into the WINDOWS or SYSTEM directory
  61. Sub DrawBackground ()
  62.     Setup1.CurrentY = 5
  63.     Setup1.CurrentX = 5
  64.     Setup1.ForeColor = QBColor(15)
  65.     Print APPNAME + " Setup"
  66. End Sub
  67. Sub Form_Load ()
  68.     '----------
  69.     ' Initialize
  70.     '----------
  71.     dialogCaption$ = APPNAME + " Setup"
  72.     ShowMainForm dialogCaption$
  73.     winDrive$ = UCase$(Left$(winDir$, 1))
  74.     winDir$ = UCase$(GetWindowsDir$())
  75.     winSysDir$ = UCase$(GetWindowsSysDir$())
  76.     '----------------------------------------------------
  77.     ' Get Window version
  78.     '----------------------------------------------------
  79.     TheVerInfo& = GetVersion()
  80.     WinVer& = TheVerInfo& And &HFFFF&
  81.     If Val(Format$(WinVer& Mod 256) + "." + Format$(WinVer& \ 256)) >= 3.1 Then
  82.         gfWin31% = True
  83.     End If
  84.     '----------------------------------------------------
  85.     ' OLE 2.0 requires Win 3.1 or greater
  86.     '----------------------------------------------------
  87.     If fOLE2% And Not gfWin31% Then
  88.         MsgBox "This application requires Windows 3.1 or later"
  89.         GoTo ErrorSetup
  90.     End If
  91.     '----------------------------------------------------
  92.     ' SETUP.EXE passes the source drive in a command
  93.     ' argument.  If it is empty,  that means the user
  94.     ' executed this .exe directly.  In that case, show
  95.     ' a dialog to get the desired source directory.
  96.     '----------------------------------------------------
  97.     SourcePath$ = Command$
  98.     If SourcePath$ = "" Then
  99.         title$ = dialogCaption$
  100.         caption1$ = "Please enter the drive or path containing the " + APPNAME + " source files."
  101.         caption2$ = "Install From:"
  102.         defaultDrive$ = "A:"
  103.         defaultText$ = "A:\"
  104.         ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$
  105.         If outButton$ = "exit" Then GoTo ErrorSetup
  106.     Else
  107.         If Right$(SourcePath$, 1) <> "\" Then
  108.             SourcePath$ = SourcePath$ + "\"
  109.         End If
  110.     End If
  111.     '--------------------
  112.     ' Get Destination Path
  113.     '--------------------
  114.     title$ = dialogCaption$
  115.     caption1$ = "If you want to install the " & APPNAME & " in a different directory and/or drive, type the name of the directory."
  116.     caption2$ = "Install To:"
  117.     defaultDrive$ = "C:"
  118.     defaultText$ = APPDIR
  119.     ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$
  120.     If outButton$ = "exit" Then GoTo ErrorSetup
  121.     '-----------------------------------------
  122.     ' Dim disk space variables as Long Integers
  123.     '-----------------------------------------
  124.     Dim winSpaceFree As Long
  125.     Dim sourceSpaceFree As Long
  126.     Dim destSpaceFree As Long
  127.     Dim totalNeeded As Long
  128.     '---------------------------------------------------------
  129.     ' If the Windows \SYSTEM directory is a subdirectory
  130.     ' of the Windows directory, the proper place for
  131.     ' installation of .VBXs and shared .DLLs is the
  132.     ' Windows \SYSTEM directory.
  133.     '
  134.     ' If the Windows \SYSTEM directory is *not* a subdirectory
  135.     ' of the Windows directory, then the user is running a
  136.     ' shared version of Windows, and the proper place for
  137.     ' installation of .VBXs and shared .DLLs is the
  138.     ' Windows directory.
  139.     '---------------------------------------------------------
  140.     If InStr(winSysDir$, winDir$) = 0 Then
  141.         winSysDir$ = winDir$
  142.     End If
  143.     '---------------------------------
  144.     ' Get Drive Letters of directories
  145.     '---------------------------------
  146.     destDrive$ = UCase$(Left$(destPath$, 1))
  147.     sourceDrive$ = UCase$(Left$(SourcePath$, 1))
  148.     '---------------------------------
  149.     ' Compute free disk space variables
  150.     '---------------------------------
  151.     winSpaceFree = GetDiskSpaceFree(winDrive$)
  152.     destSpaceFree = GetDiskSpaceFree(destDrive$)
  153.     '-----------------------------------------
  154.     ' Check for enough disk space.
  155.     '
  156.     ' Some components are being installed into the
  157.     ' Windows\SYSTEM directory.
  158.     '
  159.     ' So if the main destination path is on a
  160.     ' different drive than the drive with
  161.     ' the Windows \SYSTEM directory, we have to
  162.     ' check both drives.
  163.     '
  164.     ' An example of this is when the user is installing
  165.     ' the main product to drive D:, but the Windows
  166.     ' directory is on drive c:
  167.     ' -----------------------------------------
  168.     totalNeeded = WINSYSNEEDED + OTHERNEEDED
  169.     If winDrive$ = destDrive$ Then
  170.         If destSpaceFree < totalNeeded Then
  171.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":   An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  172.             GoTo ErrorSetup
  173.         End If
  174.     Else
  175.         If winSpaceFree < WINSYSNEEDED Then
  176.             MsgBox "There is not enough disk space on drive " + winDrive$ + ":  An estimated" + Str$(WINSYSNEEDED - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  177.             GoTo ErrorSetup
  178.         End If
  179.         If destSpaceFree < OTHERNEEDED Then
  180.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":  An estimated" + Str$(OTHERNEEDED - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  181.             GoTo ErrorSetup
  182.         End If
  183.         
  184.     End If
  185.     '----------------------------
  186.     ' Create destination directory
  187.     '----------------------------
  188.     If Not CreatePath(destPath$) Then GoTo ErrorSetup
  189.     '-----------------------------------------------------------
  190.     ' Show Status Dialog -- This stays up while copying files
  191.     ' It is required by the CopyFile routine
  192.     '-----------------------------------------------------------
  193.     ShowStatusDialog dialogCaption$, totalNeeded
  194.     '-----------
  195.     ' Copy Files
  196.     '-----------
  197.     ' Test to see if loan.exe is on the disk, if not then you know the user
  198.     ' did not insert the first disk
  199.     If Not PromptForNextDisk(1, SourcePath$ + "loan.ex_") Then GoTo ErrorSetup
  200.     ' Install loan.exe and grid.vbx in the destPath$
  201.     If Not CopyFile(SourcePath$, destPath$, "loan.ex_", "loan.exe") Then GoTo ErrorSetup
  202.     If Not CopyFile(SourcePath$, winSysDir$, "grid.vb_", "grid.vbx") Then GoTo ErrorSetup
  203.     ' If you have more than one distribution disk, call PromptForNextDisk after
  204.     ' you have installed all the files from the previous disk. This line tests to
  205.     ' see if foo.da_ is on disk 2. If not, you know the user has not inserted disk 2.
  206.     ' The call to PromptForNextDisk is commented out, since loan.exe can be installed
  207.     ' from a single distribution disk.
  208.     ' If Not PromptForNextDisk(2, SourcePath$ + "foo.da_") Then GoTo ErrorSetup
  209.     ' If Not CopyFile(SourcePath$, destPath$, "foo.da_", "foo.dat", 0) Then GoTo ErrorSetup
  210.     '--------------------------------------------------
  211.     ' File Copying is over, so unload the status dialog
  212.     '--------------------------------------------------
  213.     Unload StatusDlg
  214.     '-----------------------------------------------------------
  215.     ' Show static message while working on DDE to Program Manager
  216.     '-----------------------------------------------------------
  217.     ShowStaticMessageDialog dialogCaption$, "Creating Program Manager Icon..."
  218.     '--------------------------------------
  219.     ' Create program manager group and icon
  220.     '--------------------------------------
  221.     CreateProgManGroup Setup1, "My Loan Application", "LOAN.GRP"
  222.     CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "My Loan Application"
  223.     '-------------------------------------------------
  224.     ' Since SETUP.EXE copies your setup program to the Windows
  225.     ' directory, it is possible for your user to
  226.     ' execute this program directly.
  227.     '
  228.     ' As a usability feature, you may wish to insert code
  229.     ' here to install a program manager icon that executes
  230.     ' your setup program in the windows drive.  This
  231.     ' allows th user to re-run setup at a later time to
  232.     ' install options that were not installed the first
  233.     ' time.
  234.     '-------------------------------------------------
  235.     '-------------------
  236.     ' Hide Static Message
  237.     '-------------------
  238.     MessageDlg.Hide
  239.     '--------------------------------------------------------------
  240.     ' If OLE2.DLL already exists, then ignore the OLE 2 flag.
  241.     ' Otherwise, if we are installing an application that uses
  242.     ' OLE 2.0, we need to register the OLE 2 DLL's via REGEDIT.EXE.
  243.     '
  244.     ' Do not copy OLE dlls unless you check the versions and assure
  245.     ' that the versions you plan to install postdate the ones on
  246.     ' the users machine.
  247.     '
  248.     '
  249.     ' The data access engine and OLE 2.0 need to have SHARE.EXE
  250.     ' loaded. Check AUTOEXEC.BAT and add if needed.  NOTE: If
  251.     ' running Window For WorkGroup, then do not add SHARE.  WFW
  252.     ' use its own sharing mechanism, VSHARE.386.
  253.     '----------------------------------------------------------
  254.     If fDataAccess% Or fOLE2% And Not FileExists(winSysDir$ + "\" + "OLE2.DLL") Then
  255.         ret$ = Space$(255)
  256.         x% = GetPrivateProfileString("BOOT", "NETWORK.DRV", "", ret$, Len(ret$), "SYSTEM.INI")
  257.         If x% Then ret$ = Left(ret$, x%)
  258.         If InStr(1, UCase$(ret$), "WFWNET.DRV") = 0 Then
  259.             AddShareIfNeeded winSysDir$, "SHARE.EXE"
  260.         End If
  261.     End If
  262.     '----------------------------
  263.     ' Need to register OLE 2.0 dlls
  264.     '----------------------------
  265.     If fOLE2% And Not FileExists(winSysDir$ + "\" + "OLE2.DLL") Then
  266.         x% = Shell("regedit /s ole2.reg")
  267.     End If
  268.     '-------------------------------------------------------
  269.     ' Do not change this if statement.  Used by Setup Wizard
  270.     '-------------------------------------------------------
  271.     If fODBC% Then
  272.         CreateProgManItem Setup1, destPath$ + "ODBCADM.EXE", "ODBC Administrator"
  273.         MsgBox "Before you can run a Visual Basic ODBC application using the SQL Server driver, you must first update the ODBC catalog of stored procedures.  These procedures are provided in the INSTCAT.SQL file.  Typically, the system administrator for SQL Server should install these procedures, using the SQL Server ISQL utility."
  274.     End If
  275.     '-------------------------------------------------------
  276.     ' Do not change this if statement.  Used by Setup Wizard
  277.     '-------------------------------------------------------
  278.     If fBtrieve% Then
  279.         ' See notes in Appendix C
  280.         retstr$ = String$(255, 32)
  281.         x% = GetPrivateProfileString%("BTRIEVE", "OPTIONS", "1", retstr$, Len(retstr$), "WIN.INI")
  282.         If x% <= 1 Then
  283.             x% = WritePrivateProfileString%("BTRIEVE", "OPTIONS", "/m:64 /p:4096 /b:16 /f:20 /l:40 /n:12 /t:" + destPath$ + "BTRIEVE.TRN", "WIN.INI")
  284.         End If
  285.     End If
  286.     '------------------
  287.     ' Show Final message
  288.     '------------------
  289.     MsgBox APPNAME + " Installation is Complete!", 48, dialogCaption$
  290. ExitSetup:
  291.     Setup1.Hide
  292.     RestoreProgMan         'Show the program manager
  293.     End
  294.     Exit Sub
  295. ErrorSetup:
  296.     MsgBox APPNAME + " is not properly installed.  Please re-run setup at a later time to install the " & APPNAME & " properly.", 48, dialogCaption$
  297.     ChDrive winDrive$   ' Set back to hard disk
  298.     ChDir Left$(winDir$, Len(winDir$) - 1)
  299.     End
  300.     Exit Sub
  301. End Sub
  302. Sub Form_Paint ()
  303.     DrawBackground
  304. End Sub
  305. '---------------------------------------------------------------
  306. ' Sets the form's caption, Paints 3-D Background Text, Shows Form
  307. '---------------------------------------------------------------
  308. Sub ShowMainForm (Caption$)
  309.     Screen.MousePointer = 11
  310.     Setup1.Caption = Caption$
  311.     Setup1.Move 0, 0, Screen.Width, Screen.Height * .85
  312.     Setup1.Show
  313.     Setup1.Refresh
  314.     Setup1.ScaleMode = 2
  315.     Setup1.FontSize = 24
  316.     Setup1.FontBold = True
  317.     Setup1.FontItalic = True
  318.     DrawBackground
  319. End Sub
  320. Sub ShowPathDialog (title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$)
  321.         Screen.MousePointer = 11
  322.         Load PathDlg
  323.         PathDlg.Caption = title$
  324.         PathDlg.Label1.Caption = caption1$
  325.         PathDlg.Label2.Caption = caption2$
  326.         PathDlg.inDrive.Tag = defaultDrive$
  327.         PathDlg.Text1.Text = defaultText$
  328.         PathDlg.Text1.SelStart = 0
  329.         PathDlg.Text1.SelLength = Len(defaultText$)
  330.         CenterForm PathDlg
  331.         Screen.MousePointer = 0
  332.         PathDlg.Show 1
  333.         
  334.         SourcePath$ = PathDlg.outPath.Tag
  335.         outButton$ = PathDlg.outButton.Tag
  336.         Unload PathDlg
  337. End Sub
  338. Sub ShowStaticMessageDialog (title$, Caption$)
  339.     Load MessageDlg
  340.     CenterForm MessageDlg
  341.     MessageDlg.Caption = title$
  342.     MessageDlg.Label.Caption = Caption$
  343.     MessageDlg.Show
  344.     MessageDlg.Refresh
  345. End Sub
  346. Sub ShowStatusDialog (title$, totalBytes As Long)
  347.     Load StatusDlg
  348.     StatusDlg.Caption = title$
  349.     StatusDlg.total.Tag = Str$(totalBytes)
  350.     CenterForm StatusDlg
  351.     StatusDlg.Show
  352. End Sub
  353.